<template>
  <div class="app-container">
    <!-- 顶部导航栏 -->
    <el-menu
        mode="horizontal"
        class="top-nav"
        :ellipsis="false"
        background-color="#fff">
      <div class="nav-left">
        <el-menu-item index="1">手机</el-menu-item>
        <el-menu-item index="2">电视</el-menu-item>
        <el-menu-item index="3">笔记本</el-menu-item>
      </div>
      <div class="flex-grow" />
      <div class="nav-right">
        <el-menu-item index="4">
          <el-icon><User /></el-icon>登录
        </el-menu-item>
        <el-menu-item index="5">
          <el-icon><UserFilled /></el-icon>注册
        </el-menu-item>
        <el-menu-item index="6">
          <el-badge :value="3" class="notification-badge">
            <el-icon><Bell /></el-icon>消息通知
          </el-badge>
        </el-menu-item>
        <el-menu-item index="7">
          <el-badge :value="2" class="cart-badge">
            <el-icon><ShoppingCart /></el-icon>购物车
          </el-badge>
        </el-menu-item>
      </div>
    </el-menu>

    <div class="main-container">
      <!-- 左侧分类栏 -->
      <el-menu
          class="category-sidebar"
          default-active="1">
<!--        <el-menu-item v-for="(item, index) in categories"-->
<!--                      :key="index"-->
<!--                      :index="String(index + 1)">-->
<!--          <el-icon><component :is="item.icon" /></el-icon>-->
<!--          <span>{{ item.name }}</span>-->
<!--        </el-menu-item>-->
        <el-menu-item index="8">
          <el-icon><Iphone /></el-icon>手机
        </el-menu-item>
      </el-menu>

      <!-- 主要内容区 -->
      <div class="content-area">
        <!-- 横幅广告 -->
        <el-card class="banner">
          <div class="banner-content">
            <h1>Redmi Turbo 4</h1>
            <p class="slogan">旗舰性能 超级能效</p>
            <p class="price">¥1999 起</p>
            <el-button type="danger" size="large">立即抢购</el-button>
          </div>
        </el-card>

        <!-- 产品展示区 -->
        <div class="products-grid">
          <el-card v-for="product in products"
                   :key="product.id"
                   class="product-card">
            <img :src="product.image" :alt="product.name">
            <h3>{{ product.name }}</h3>
            <p>{{ product.description }}</p>
            <p class="price">{{ product.price }} 起</p>
            <el-button type="primary">了解详情</el-button>
          </el-card>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import {ref} from 'vue'
import {
  User,
  UserFilled,
  Bell,
  ShoppingCart,
  Iphone,
  Monitor,
  Laptop,
  Watch,
  House,
  Box
} from '@element-plus/icons-vue'

const categories = ref([
  {name: '手机', icon: 'Iphone'},
  {name: '电视', icon: 'Monitor'},
  {name: '笔记本', icon: 'Laptop'},
  {name: '平板', icon: 'Monitor'},
  {name: '智能穿戴', icon: 'Watch'},
  {name: '智能家居', icon: 'House'},
  {name: '配件', icon: 'Box'}
])

const products = ref([
  {
    id: 1,
    name: 'Xiaomi 15 系列',
    description: '年度旗舰 | 徕卡光学',
    price: '¥3999',
    image: '/images/xiaomi15.jpg'
  },
  {
    id: 2,
    name: 'Redmi 电视 X 2025',
    description: '4K超高清 | 全面屏设计',
    price: '¥2499',
    image: '/images/redmi-tv.jpg'
  },
  {
    id: 3,
    name: 'Xiaomi Watch S4',
    description: 'AMOLED高清屏 | 14天续航',
    price: '¥999',
    image: '/images/watch.jpg'
  }
])
</script>

<style scoped>
.app-container {
  min-height: 100vh;
  background-color: #f5f5f5;
}

.top-nav {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
}

.flex-grow {
  flex-grow: 1;
}

.main-container {
  display: flex;
  max-width: 1200px;
  margin: 60px auto 0;
  padding: 20px;
  gap: 20px;
}

.category-sidebar {
  width: 200px;
  height: fit-content;
  position: sticky;
  top: 80px;
  border-radius: 4px;
}

.content-area {
  flex: 1;
}

.banner {
  margin-bottom: 20px;
  height: 400px;
  background: linear-gradient(to right, #ff6700, #ff9066);
  color: white;
}

.banner-content {
  padding: 40px;
}

.banner-content h1 {
  font-size: 42px;
  margin-bottom: 20px;
}

.banner-content .slogan {
  font-size: 24px;
  margin-bottom: 20px;
}

.banner-content .price {
  font-size: 32px;
  margin-bottom: 30px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.product-card {
  text-align: center;
}

.product-card img {
  width: 100%;
  height: auto;
  margin-bottom: 15px;
}

.product-card h3 {
  margin: 10px 0;
  color: #333;
}

.product-card .price {
  color: #ff6700;
  font-size: 18px;
  font-weight: bold;
  margin: 10px 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
    padding: 10px;
  }

  .category-sidebar {
    width: 100%;
    position: static;
  }

  .products-grid {
    grid-template-columns: 1fr;
  }

  .banner {
    height: 300px;
  }

  .banner-content {
    padding: 20px;
  }

  .banner-content h1 {
    font-size: 32px;
  }
}
</style>